Repository navigation
#241 - Fix CsvWriterTask: non-array input without headers, execution after finalize() - #247
Merged
Merged
Conversation
…nted `\UnexpectedValueException` instead of a `TypeError` when `headers` is `null`, and the CSV tasks release their file on `finalize()` so that the task can be executed again. Update documentation, add tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
njoubert-cleverage
force-pushed
the
241
branch
from
October 9, 2026 09:24
0411c58 to
ac433b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #241.
headers: null:CsvWriterTask::getHeaders()calledarray_keys($state->getInput())when opening the file, before the input was validated, so a non-array input threw a rawTypeError. The input is now checked first and the documented\UnexpectedValueException('Input value is not an array')is thrown (same exception as with staticheaders), before the file is created.finalize():AbstractCsvResourceTask::finalize()closed the file without resetting$this->csv, so a second execution of the same instance threwCSV file '...' was closed earlier. It is now reset tonull. This does not happen through theProcessManager(task services are not shared), but makes the CSV tasks consistent withCsvSplitterTask, which already did it in its ownfinalize()(now identical to the parent one, left untouched to stay in scope).CsvReaderTask/InputCsvReaderTaskinherit it: callingfinalize()before the end of the file no longer prevents a following read.Documentation:
docs/reference/tasks/csv_writer_task.md(non-array input). Tests:CsvWriterTaskTest::testThrowsWhenInputIsNotAnArrayWithoutStaticHeadersandtestCanWriteAgainAfterFinalize, both failing onmainfor the reported reasons.PHPUnit (803 tests), PHPStan, PHP-CS-Fixer and Rector pass, and the changed files are valid PHP 8.2.
Requirements
Breaking changes
None: both cases currently throw (a
TypeErrorand aRuntimeException).🤖 Generated with Claude Code